Skip to content

Add Compat class for aliasing core MediaWiki classes#21

Open
WikiMANNia wants to merge 1 commit intomywikis:mainfrom
WikiMANNia:patch-2
Open

Add Compat class for aliasing core MediaWiki classes#21
WikiMANNia wants to merge 1 commit intomywikis:mainfrom
WikiMANNia:patch-2

Conversation

@WikiMANNia
Copy link
Copy Markdown

No description provided.

@jeffw16
Copy link
Copy Markdown
Member

jeffw16 commented Mar 29, 2026

Thanks for this proposed change.

It's not clear to me why this is necessary though; would you be able to elaborate?

To ensure an atomic update, would you please combine all file changes for the same feature into one pull request?

Please note that, as of 1.2.0, MediaWiki 1.35 is no longer supported due to the difficulty of running the workflows to test it.

@WikiMANNia
Copy link
Copy Markdown
Author

This way to manage backward compatibility will no longer disturbing code

@WikiMANNia
Copy link
Copy Markdown
Author

WikiMANNia commented Mar 29, 2026

To ensure an atomic update, would you please combine all file changes for the same feature into one pull request?

How can I do it?

@jeffw16
Copy link
Copy Markdown
Member

jeffw16 commented Mar 29, 2026

This way to manage backward compatibility will no longer disturbing code

Sorry, I don't understand what this means…

To ensure an atomic update, would you please combine all file changes for the same feature into one pull request?

How can I do it?

You can go to this patch's branch (https://github.com/WikiMANNia/Mediawiki-Extension-CrawlerProtection/tree/patch-2) and make the changes in there. They'll automatically be reflected in this PR.

@WikiMANNia
Copy link
Copy Markdown
Author

You can go to this patch's branch (https://github.com/WikiMANNia/Mediawiki-Extension-CrawlerProtection/tree/patch-2) and make the changes in there.

I didn't see it. Thank for indicating me!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new compatibility helper intended to provide cross-MediaWiki-version support by aliasing legacy core class names to newer namespaced equivalents.

Changes:

  • Add includes/Compat.php with a Compat class and an init() entrypoint.
  • Implement class_alias mappings for several core classes (Title, OutputPage, WebRequest, SpecialPage, User, ActionEntryPoint, Article).

Comment on lines +1 to +5
<?php

namespace MediaWiki\Extension\CrawlerProtection;

class Compat {
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file is missing the standard file header used elsewhere in this extension (license block + @file tag). Keeping headers consistent helps with licensing compliance and makes files easier to audit.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +12
public static function init(): void {
self::aliasCoreClasses();
}

private static function aliasCoreClasses(): void {

Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat::init() is never called (no references found in the repo, and extension.json doesn’t register a callback), so the class aliases in this file currently never take effect. Either wire this up to run during extension registration (early enough to affect any use/autoloading) or remove the unused compat layer to avoid misleading future maintainers.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +29
if ( class_exists( \ActionEntryPoint::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \ActionEntryPoint::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActionEntryPoint aliasing here appears to target the wrong legacy class. The existing compat logic in this extension aliases \\MediaWiki to \\MediaWiki\\Actions\\ActionEntryPoint for older MediaWiki versions; using \\ActionEntryPoint as the source class likely won’t work on those versions (the class may not exist). Align the alias source/target with the actual legacy class name used by core.

Suggested change
if ( class_exists( \ActionEntryPoint::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \ActionEntryPoint::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */
if ( class_exists( \MediaWiki::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \MediaWiki::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +12
class Compat {

public static function init(): void {
self::aliasCoreClasses();
}

private static function aliasCoreClasses(): void {

Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is inconsistent with the MediaWiki convention used in the rest of this extension (tabs for indentation). This file mixes spaces and tabs (e.g., method bodies and closing braces), which will cause avoidable style diffs and can trip PHPCS.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants